export const pattern = {
    phoneReg: /^1\d{10}$/,
    emailReg: /^([0-9A-Za-z\-_.]+)@([0-9A-Za-z\-_.]+\.[A-Za-z]{2,3})$/,
    passwordReg:
        /^(?![0-9]+$)(?![a-zA-Z]+$)(?![!@#$%./*()_+^&]+$)[0-9A-Za-z!@#$%./*()_+^&]{8,32}$/,
    //社会信用代码
    SociologyId: /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/,
    //身份证号码
    identityCard:
        /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
    //千分位，4位小数
    thousandAccount: /^(\d+(,\d\d\d)*(\.\d{1,4})?)$/,
    //折扣率，(0-100]之间
    discountRate: /^((?!0+(?:\.0+)?$)(?:[1-9]\d*|0))(?:\.\d{1,2})?$/,
    //大于0精确到2位小数
    acountTwoDecimal: /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/,
    //匹配正数包括0和小数
    positiveNumber: /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/,
};

export const checkSpecialKey = function (str) {
    var specialKey =
        "[`@~!#$^&*()=|{}':;'\\[\\].<>/?~！#￥……&*（）——|{}【】‘；：”“'。，、？]‘'";
    for (var i = 0; i < str.length; i++) {
        if (specialKey.indexOf(str.substr(i, 1)) != -1) {
            return false;
        }
    }
    return true;
};
